<template>
  <div id="app">
    <keep-alive>
      <router-view v-if="$route.meta.keepAlive"></router-view>
    </keep-alive>
    <router-view v-if="!$route.meta.keepAlive"></router-view>
  </div>
</template>
<script>
// import cloneDeep from 'lodash/cloneDeep'
export default {
  name: 'app',
  data () {
    return {
    }
  },
  watch: {
  },
  created () {
    this.setState()
  },
  methods: {
    /*
       *@author wf_Huang
       *@Time 2019/7/19 0019 17:46
       *@function  防止刷新丢失数据
       *****************************************/
    setState () {
      // 存储
      // this.$store.state.openid = 88833888
      // localStorage.setItem('stateData', JSON.stringify(this.$store.state))
      const data = JSON.parse(localStorage.getItem('stateData'))
      if (data) {
        this.$store.replaceState(Object.assign({}, this.$store.state, data))
        // 判断是不是要版本迭代清除缓存 大量存储参数时会遇到行添加的state 值无法生效的问题
        if (this.$store.state.version !== '1.0.0.9') {
          localStorage.removeItem('stateData')
        }
      }
    }
  },
  mounted () {
  },
  components: {
  }
}
</script>
